<?php
declare(strict_types=1);
namespace Field;

class StoreProductContentConst
{
    public const pk='ProductID';
    public const index=['ProductID'];
	public const fields=['ProductID','CreateAt','UpdateAt'];
	public const comment=['ProductID'=>'商品id','CreateAt'=>'添加时间','UpdateAt'=>''];
	/*
    * @Field ProductID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra auto_increment
    * @Privileges select,insert,update,references
    * @Comment 商品id
    */
    public const ProductID = 'ProductID';
    /*
    * @Field CreateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 添加时间
    */
    public const CreateAt = 'CreateAt';
    /*
    * @Field UpdateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra on update CURRENT_TIMESTAMP
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const UpdateAt = 'UpdateAt';
}

class StoreProductContentColumns
{
public  int $ProductID;
   public  ?string $CreateAt='';
   public  ?string $UpdateAt='';
	public function toArray():array
	{
		return [
'ProductID'=>$this->ProductID,
    'CreateAt'=>$this->CreateAt,
    'UpdateAt'=>$this->UpdateAt,        ];
	}
}

class StoreProductContentRow
{
	public StoreProductContentColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'ProductID' => $this->data->ProductID,
        'CreateAt' => $this->data->CreateAt,
        'UpdateAt' => $this->data->UpdateAt, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new StoreProductContentColumns();
        isset($data['ProductID']) && $this->data->ProductID = (int)$data['ProductID'];
           isset($data['CreateAt']) && $this->data->CreateAt = (string)$data['CreateAt'];
           isset($data['UpdateAt']) && $this->data->UpdateAt = (string)$data['UpdateAt'];
    }
}
?>